<?php
session_start();
include('../include/util.inc.php');
$PDO = getPDO();
if (isset($_SESSION['uid'])) {
    $datetime = $_GET['datetime'];
    $uid = $_SESSION['uid'];
    $hid = str_pad($uid, 4, '0', STR_PAD_LEFT) . $datetime;
    $hid = $PDO->quote($hid);
    $hid = str_replace('?', '', $hid);
    try{
        $sql = "SELECT * FROM detail WHERE `hid` = $hid;";
        $result = $PDO->query($sql);
        $result = $result->fetchAll();
        $sql = "SELECT * FROM history WHERE `hid` = $hid";
        $result2 =  $PDO->query($sql);
        $result2 = $result2->fetchAll();
        $res = ['basic' => $result2, 'detail' => $result];
        echo json_encode($res);
    }catch (PDOException $e) {
        echo $e->getMessage();
    }
    
}else{
    echo 'customer';
}


?>